/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package FeeDeposit;

import Admission.AdmissionBean;
import FeeType.FeeTypeBean;
import Student.StudentBean;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author mishra
 */
public class StudentFeeDetails extends HttpServlet {

    
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, SQLException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            String Email=request.getParameter("uid");
            Vector<AdmissionBean> list=FeeDeposit.Query.viewAllStuFeeDeposit(Email);
            if(!list.isEmpty()){
            Iterator it=list.iterator();
            while(it.hasNext()){
                AdmissionBean ab=(AdmissionBean) it.next();
                FeeDepositBean fdb = ab.getFeeDepositBean();
                FeeTypeBean ftb= fdb.getFeeTypeBean();
                StudentBean sb= ab.getStudentBean();
               //out.println("<tr><td>"+ab.getApplicationNo()+"<td></tr>");
            out.println("<tr id='"+ab.getAddmissionId()+"'>");                            
            out.println("<center><td>"+ftb.getFeeTypeName()+"</td></center>");                                
            out.println("<td>"+fdb.getReceiptNo()+"</td>");
            out.println("<td>"+fdb.getAmount()+"</td>");
            if(fdb.getPayMode()==0){
            out.println("<td>Cash</td>");  
            } else if(fdb.getPayMode()==1){
            out.println("<td>Cheque</td>");  
            }else if(fdb.getPayMode()==2){
            out.println("<td>Demand Draft</td>");  
            }
            out.println("<td>"+fdb.getStudSession()+"</td>"); 
            out.println("<td>"+fdb.getSemester()+"</td>"); 
            out.println("<td>"+fdb.getEntryDate()+"</td>"); 
            out.println("</tr>"); 
            }
            }else
            {
               out.println("<tr>");
               out.println("<td colspan='3'>");
               out.println("<b>No Record Found</b>");
               out.println("</td>");
               out.println("</tr>");
            }
           }catch(Exception e){
            out.println(e);
        } finally {
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            processRequest(request, response);
        } catch (SQLException ex) {
            Logger.getLogger(StudentFeeDetails.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            processRequest(request, response);
        } catch (SQLException ex) {
            Logger.getLogger(StudentFeeDetails.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
